<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <title>宠物知识|蜗牛宠物领养平台</title>

    <link rel="shortcut icon" th:href="@{/asserts/images/favicon.ico}" type="image/x-icon"/>
    <!-- Bootstrap的css -->
    <link rel="stylesheet" th:href="@{/asserts/bootstrap3.4.1/css/bootstrap.min.css}">
    <!-- jQuery本地-->
    <script th:src="@{/asserts/js/jQuery-3.6.0.js}"></script>
    <!-- 加载本地js -->
    <script th:src="@{/asserts/bootstrap3.4.1/js/bootstrap.min.js}"></script>
    <!-- 加载common.css -->
    <link rel="stylesheet" th:href="@{/asserts/css/common.css}"/>
    <!-- 加载页头页尾css -->
    <link rel="stylesheet" th:href="@{/asserts/css/top.css}"/>
    <link rel="stylesheet" th:href="@{/asserts/css/foot.css}"/>
    <!-- 加载页头页尾js -->
    <script th:src="@{/asserts/js/top.js}"></script>

    <style>
        .li-article > div {
            margin-bottom: 20px;
        }


    </style>

</head>
<body>
<!-- 页头 -->
<nav th:replace="nav::headerBar"></nav>
<div class="container">

    <div style="height: 100px"><h1>宠物知识列表</h1></div>

    <div th:if="${petArticlePageInfo!=null}">
        <li th:each="p : ${petArticlePageInfo.list}" style="margin-bottom: 20px ; overflow:hidden" class="li-article">
            <div style="height: 210px ;
                 width: 210px ;
                 color: #0f0f0f;
                 font-size: 20px;
                 float: left ;">
                <img th:src="${p.image}"
                     style="width: 200px;height:200px; border-radius: 5px; cursor: pointer;">
                <!--                <img src=""-->
                <!--                     style="width: 200px;height:200px; border-radius: 5px; cursor: pointer;">-->
                <!--                <span th:text="${p.image}"></span>-->
            </div>

            <div>
                <h3>
                    <a th:href="@{/petArticle/detail/(id=${p.id})}" th:text="${p.title}"></a>
                </h3>
            </div>

            <div>
                <p th:text="${p.introduce}"></p>
            </div>

            <div>
                <label>访问量 : </label><span th:text="${p.views}"></span>
            </div>
            <div>
                <label>最近更新时间 : </label>
                <span th:text="${#dates.format(p.updateTime, 'yyyy-MM-dd')}"></span>
            </div>
        </li>
    </div>
    <div>
        <span class="btn-lg" style="margin-left: 100px;">总数:</span><span class="btn-lg"
                                                                         th:text="${petArticlePageInfo.total}"></span>
        <span class="btn-lg">总页数:</span><span class="btn-lg" th:text="${petArticlePageInfo.pages}"></span>
        <span class="btn-lg">当前页:</span><input id="jumpNow" style="width: 25px;"
                                               th:value="${petArticlePageInfo.pageNum}">
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <button type="button" class="btn btn-success" onclick="jump()">跳转</button>
        <button type="button" class="btn btn-success btn-lg" style="margin-left: 100px;" onclick="go(1)">首页</button>
        <button type="button" class="btn btn-success btn-lg" th:onclick="go([[${petArticlePageInfo.prePage}]])">上一页
        </button>
        <button type="button" class="btn btn-success btn-lg" th:onclick="go([[${petArticlePageInfo.nextPage}]])">下一页
        </button>
        <button type="button" class="btn btn-success btn-lg" th:onclick="go([[${petArticlePageInfo.pages}]])">尾页
        </button>
    </div>
</div>

<!-- 页尾 -->
<footer th:replace="nav::footBar"></footer>

<script>
    function go(now) {
        now = now === 0 ? 1 : now;
        let url = '[[@{/petArticle/list}]]' + '?pageNum=' + now;
        window.location.href = url;
    }

    function jump() {
        let now = $("#jumpNow").val();
        go(now);
    }


</script>
</body>
</html>